//
//  CMDBListCell.swift
//  CMDB
//
//  Created by 曹桂祥 on 17/4/9.
//  Copyright © 2017年 CMDB. All rights reserved.
//

import UIKit

class CMDBListCell: CustomBaseCell {

    var titlelabel    : UILabel!
    var subTitleLabel : UILabel!
    
    override func setupCell() {
        
        super.setupCell()
    }
    
    override func cellBuildSubViews() {
        
        titlelabel      = UILabel(frame: CGRect(x: 10, y: 8, width: 320, height: 25))
        titlelabel.font = CMDB_16_FONT
        contentView.addSubview(titlelabel)
        
        subTitleLabel           = UILabel(frame: CGRect(x: 10, y: 35, width: 320, height: 10))
        subTitleLabel.font      = CMDB_12_FONT
        subTitleLabel.textColor = UIColor.lightGrayColor()
        contentView.addSubview(subTitleLabel)
        
    }
    
    override func loadContent() {
        let data = cellData as! CMDBDynamicBean
        
        titlelabel.text = data.user?.name
        
        subTitleLabel.text = data.content
        
    }
    
    override func update(data: AnyObject?) {
        
        let data = data as! CMDBDynamicBean
        
        titlelabel.text = data.user?.name
        
        subTitleLabel.text = data.content
        
    }
    
    override func setHighlighted(highlighted: Bool, animated: Bool) {
        
        UIView.animateWithDuration(0.35, delay: 0, options: .BeginFromCurrentState, animations: {
            self.titlelabel.alpha = (highlighted == true ? 0.5    : 1.0)
            self.subTitleLabel.x  = (highlighted == true ? 10 + 4 : 10)
            self.backgroundColor  = (highlighted == true ? UIColor.Hex6(0x4699D9, alpha: 0.35) : UIColor.whiteColor())
            }, completion: nil)
    }
}
